package com.cdtye.itps.cms.dao.detect;

import com.baomidou.mybatisplus.annotation.*;
import com.cdtye.itps.cms.dao.defect.entity.JcwProblemDefectReason;
import com.cdtye.itps.cms.dao.enums.DelFlagEnum;
import com.google.gson.Gson;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.util.Date;

@TableName("JCW_DEFECT_REASON")
@Data
@ApiModel("检测监测缺陷成因段级表")
public class JcjcDefectReasonSection {
    private static final long serialVersionUID = 1L;

    /**
     * 缺陷成因名称
     */
    @TableField("DEFECT_REASON_NAME")
    private String defectReasonName;

    /**
     * 缺陷成因编号
     */
    @TableField("REASON_CODE")
    private String reasonCode;

    /**
     * 缺陷成因级联码
     */
    @TableField("DEFECT_REASON_NO")
    private String defectReasonNo;

    /**
     * 父级id
     */
    @TableField("PARENT_ID")
    private String parentId;


    /* *//**
     * id的路径
     *//*
    @TableField("ID_PATH")
    private String idPath;*/


    /**
     * 描述
     */
    @TableField("REMARK")
    private String remark;

    /**
     * 排序号
     */
    @TableField("SORT_NUM")
    private String sortNum;

    @TableId(value = "DEFECT_REASON_ID", type = IdType.ASSIGN_UUID)
    private String defectReasonId;

    @ApiModelProperty("创建时间")
    @TableField(value ="CREATE_DATETIME", fill = FieldFill.INSERT)
    private Date createDatetime;

    @ApiModelProperty("更新时间")
    @TableField(value ="UPDATE_DATETIME",fill = FieldFill.INSERT_UPDATE)
    private Date updateDatetime;

    @ApiModelProperty("删除标志，Y=是，N=否")
    @TableField(value ="DEL_FLAG", fill = FieldFill.INSERT)
    private String delFlag;

    @ApiModelProperty("创建人")
    @TableField(value ="CREATE_BY", fill = FieldFill.INSERT)
    private String createBy;

    @ApiModelProperty("更新人")
    @TableField(value ="UPDATE_BY",fill = FieldFill.INSERT_UPDATE)
    private String updateBy;

    public JcwProblemDefectReason covEntity() {
        Gson gs = new Gson();
        String listStr = gs.toJson(this);
        JcwProblemDefectReason jcwProblemDefectReasonBureau = gs.fromJson(listStr, JcwProblemDefectReason.class);
//        jcwProblemDefectReasonBureau.setId(null);
        jcwProblemDefectReasonBureau.setReasonName(this.defectReasonName);
        jcwProblemDefectReasonBureau.setReasonCode(this.getDefectReasonNo());
        jcwProblemDefectReasonBureau.setUpdateDatetime(new Date());
        jcwProblemDefectReasonBureau.setCreateDatetime(new Date());
        jcwProblemDefectReasonBureau.setDelFlag(DelFlagEnum.NO);
        return jcwProblemDefectReasonBureau;
    }
}
